package com.gve.main;
import java.util.ArrayList;
import java.util.List;

import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;

import com.gve.model.Car;
import com.gve.model.Person;
import com.gve.model.Stu;

/**
 * Created by ming on 2018/5/24.
 */
public class Test {

    public static void main(String[] args) {
    	KieServices kieServices = KieServices.Factory.get();
		// 默认自动加载 META-INF/kmodule.xml
		KieContainer kieContainer = kieServices.getKieClasspathContainer();
		// kmodule.xml 中定义的 ksession name
		KieSession kieSession = kieContainer.newKieSession("all-rules");

        List<Stu> list = getStus();
        for (Stu stu : list) {
        	kieSession.insert(stu);
        }
        int count = kieSession.fireAllRules();
        System.out.println(count);
        System.out.println("end....");
    }

    public static List<Stu> getStus() {
        List<Stu> stus = new ArrayList<Stu>();
        stus.add(new Stu("张三", 16, "male"));
        stus.add(new Stu("huhu", 18, "male"));
        stus.add(new Stu("王五", 32, "male"));
        stus.add(new Stu("张红", 23, "female"));
        stus.add(new Stu("李四", 35, "male"));
        stus.add(new Stu("张小雅", 31, "female"));
        return stus;
    }
}